package com.lsmw.commonutils;

import com.google.gson.Gson;

import java.util.Map;

/*
 *ClassName:ParseR
 *UserName:三号男嘉宾
 *CreateTime:2021-03-29
 *Description:用于解析R数据
 */
public class ParseR {

    public class Admin {

        private Map<String, Object> admin;

        public Admin(R r) {
            Map<String, Object> data = r.getData();
            if(data.get("admin") != null){
                String s = String.valueOf(data.get("admin"));
                Map<String, Object> map = new Gson().fromJson(s, Map.class);
                this.admin = map;
            }else if(data.get("msg") != null){
                this.admin = data;
            }
        }

        public Long getAdminId() {
            Object adminId = admin.get("adminId");
            return adminId != null ? Long.valueOf(String.valueOf(adminId)):null;
        }

        public String getAdminName() {
            Object adminName = admin.get("adminName");
            return adminName != null ? String.valueOf(adminName) : null;
        }

        public String getAdminPwd() {
            Object adminPwd = admin.get("adminPwd");
            return  adminPwd != null ? String.valueOf(adminPwd) : null;
        }

        public Boolean getAdminAuth() {
            Object adminAuth = admin.get("adminAuth");
            return adminAuth != null ? Boolean.valueOf(String.valueOf(adminAuth)) : null;
        }

        public Boolean getIsDeleted() {
            Object isDeleted = admin.get("isDeleted");
            return isDeleted != null ? Boolean.valueOf(String.valueOf(isDeleted)) : null;
        }

        public String getMsg() {
            Object msg = admin.get("msg");
            return msg != null ? String.valueOf(msg) : null;
        }

        public boolean isMsg(){
            return admin.get("msg") != null ? true : false;
        }

        @Override
        public String toString() {
            return this.admin.toString();
        }
    }

}
